package org.learn.wsstomp.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

/**
 * 〈DESCRIPTION〉
 *
 * @author xl
 * @version 1.0.0
 * @date 2019/6/17 21:02
 */
@Controller
public class MacController {

    private static final Logger logger = LoggerFactory.getLogger(MacController.class);

    @MessageMapping("/macsimp")
    @SendTo("/exchange/amq.topic/simp")
    public String mac(String message) {
        logger.info(">>>  receive: " + message);

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return message;
    }

    @MessageMapping("/announcement")
    @SendTo("/topic/announcement")
    public String announcement(String message) {
        logger.info(">>>  receive: " + message);
        return message;
    }

}
